<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<%@ include file="/static/admin/jsp/include.jsp"%>

	<script type="text/javascript">
        var grid;
        var index;

        var addFun = function($dialog, $grid, $pjq) {
            var dialog = parent.sy.modalDialog({
                title : '新增',
                width : 800,
                height : 600,
                url : sy.contextPath + '/go?path=chemical/ageParam/ageParamEdit',
                buttons : [ {
                    text : '保存',
                    handler : function() {
                        dialog.find('iframe').get(0).contentWindow.submitForm(dialog, grid, parent.$);
                    }
                } ]
            });
        };

        var editFun = function($dialog, $grid, $pjq) {
            var rows = grid.datagrid('getSelections');
            if (rows.length != 1) {
                parent.$.messager.w('请选择一条记录进行编辑！');
                return;
            }
            var dialog = parent.sy.modalDialog({
                title : '修改',
                width : 800,
                height : 600,
                //url : sy.contextPath + '/go?path=goods/goodsEdit&id=' + rows[0].id,
                url : sy.contextPath + '/go?path=chemical/ageParam/ageParamEdit&id=' + rows[0].id,
                buttons : [ {
                    text : '保存',
                    handler : function() {
                        dialog.find('iframe').get(0).contentWindow.submitForm(dialog, grid, parent.$);
                    }
                } ]
            });
        };

        function getConNum (id){
            var url = sy.contextPath + '/goods/getConNum';
            $.post(url, {id : id}, function() {
                grid.datagrid('reload');
            }, 'json');
		}

        $(function() {
            grid = $('#grid').datagrid({
                url : sy.contextPath + '/xAxis/list',
                singleSelect : false,
                frozenColumns : [ [ {
                    width : '100',
                    checkbox:true,
                    field : 'id',
                    align : 'center'
                }] ],
                columns : [ [ {
                    width : $(this).width() * 0.05,
                    title : '年龄跨度',
                    field : 'ageRange',
                    align : 'center',
                },{
                    width : $(this).width() * 0.08,
                    title : '年龄间隔',
                    field : 'ageSpace',
                    align : 'center',
                },{
                    width : $(this).width() * 0.05,
                    title : '创建时间',
                    field : 'createTime',
                    align : 'center',
                }
                ] ]
            });
        });

        function SaveData(data) {
            var url = sy.contextPath + '/chemicalType/save';
            $.post(url, data, function() {
                grid.datagrid('reload');
            }, 'json');
        }

        /**
         * 导出excel
         */
        function exportExcel(){
            var url = sy.contextPath + '/goods/exportExcel';
            location.href=url;
        }
	</script>
</head>
<body>
<div id="toolbar">
	<form id="searchForm">

	</form>
	<div class="tbbutton">

		<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'fa-plus-circle',plain:true" onclick="addFun();">添加</a>
		<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'fa-pencil',plain:true" onclick="editFun();">修改</a>

		<%--<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'fa-trash',plain:true" onclick="delFun();">删除</a>--%>

	</div>
</div>
<table id="grid" data-options="fit:true,border:false"></table>
</body>
</html>